{extend name="public:base" /}

{block name="css"}
<link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css"/>
<link href="__ADMIN__/css/style.css" rel="stylesheet">{block name="content"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox ">
                <div class="ibox-content ">
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th>商品名称</th>
                                <th>商品图片</th>
                                <th>商品属性</th>
                                <th>商品数量</th>
                                <th>单价</th>
                                <th>查看评论</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name="order_vice" id="vo"}
                            <tr>
                                <td>{$vo.name}</td>
                                <td><img class="upload-file" src="{:getPicture($vo.img)}"></td>
                                <td>{$vo.suk_name_str}</td>
                                <td>{$vo.count}</td>
                                <td>{$vo.price}</td>
                                <td>
                                    {if condition="$vo['is_comment'] gt 0"}
                                    <a href="{:url('doComment', ['id' => $vo['is_comment'],])}" class="btn btn-white btn-sm">
                                        <i class="iconfont icon-edit"></i> 查看评论
                                    </a>
                                    {else/}
                                    暂未评论
                                    {/if}
                                </td>
                            </tr>
                            {/volist}
                            </tbody>
                        </table>
                        {if $info.lottery_coupon_name}
                        <h3 style="margin-top: 40px">使用实物券：<span style="color: red">{$info.lottery_coupon_name}</span>
                        </h3>
                        {/if}
                    </div>
                </div>
            </div>

            <div class="ibox ">
                <div class="ibox-content">
                    <div class="box-item">
                        <div class="form-group row"><label class="col-sm-1 col-form-label">订单信息</label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" value="订单号：{$info.order_sn}" readonly>
                            </div>

                            <div class="col-sm-3">
                                <input type="text" class="form-control" value="总金额：{$info.all_price}" readonly>
                            </div>

                            <style>
                                .zf-box {
                                    display: flex;
                                }

                                .zf-text {
                                    display: flex;
                                    align-items: center;
                                    justify-content: center;
                                    width: 120px;
                                    padding: 7px 0;
                                    border: 1px solid #e5e5e5;
                                }
                            </style>

                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="pay_price" value="支付金额：{$info.pay_price}" readonly>
                            </div>
                        </div>
                    </div>

                    <div class="box-item">
                        <div class="form-group row">
                            <label class="col-sm-1 col-form-label"></label>

                            <div class="col-sm-3">
                                <select class="form-control" disabled>
                                    <!-- 订单状态；1：待发货，2：待收货，3：待评价，4：已完成，5：已退款 -->
                                    <option value="1" {$info[
                                    'status'] == 1 ? 'selected' : ''}>订单状态：待发货</option>
                                    <option value="2" {$info[
                                    'status'] == 2 ? 'selected' : ''}>订单状态：待收货</option>
                                    <option value="3" {$info[
                                    'status'] == 3 ? 'selected' : ''}>订单状态：待评价</option>
                                    <option value="4" {$info[
                                    'status'] == 4 ? 'selected' : ''}>订单状态：已完成</option>
                                    <option value="5" {$info[
                                    'status'] == 5 ? 'selected' : ''}>订单状态：已退款</option>
                                </select>
                            </div>

                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="pay_price" value="支付金额：{$info.pay_type == 1 ? '微信支付' : '余额支付'}" readonly>
                            </div>
                        </div>
                    </div>

                    <div class="box-item">
                        <div class="form-group row"><label class="col-sm-1 col-form-label"></label>
                            <div class="col-sm-3">
                                <select class="form-control" disabled>
                                    <option value="0" {$info[
                                    'is_pay'] == 0 && $info['is_pay'] !='' ? 'selected' : ''}>支付状态：未支付</option>
                                    <option value="1" {$info[
                                    'is_pay'] == 1 ? 'selected' : ''}>支付状态：已支付</option>
                                </select>
                            </div>

                            <div class="col-sm-3">
                                <input type="text" class="form-control" value="支付时间：{$info.pay_time?timeFormat($info.pay_time):'未支付'}" readonly>
                            </div>

                            <div class="col-sm-3">
                                <input type="text" class="form-control" value="备注：{$info.remark}" readonly>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="ibox-content">
                    <div class="box-item">
                        <div class="form-group row"><label class="col-sm-1 col-form-label">收货信息</label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" value="收货时间：{$info.complete_time?timeFormat($info.complete_time):'未收货'}" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="box-item">
                        <div class="form-group row"><label class="col-sm-1 col-form-label"></label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" value="姓名：{$info.get_username}" readonly>
                            </div>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" value="手机号：{$info.get_mobile}" readonly>
                            </div>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" value="地址：{$info.get_address}" readonly>
                            </div>
                        </div>
                    </div>
                </div>
                {if $info['status'] == 1}
                <div class="ibox-content">
                    <div class="box-item">
                        <div class="form-group row"><label class="col-sm-1 col-form-label">发货</label>
                            <div class="col-sm-3">
                                <input type="text" placeholder="请输入物流公司" class="form-control shipper_name" value="">
                            </div>
                            <div class="col-sm-3">
                                <input type="text" placeholder="请输入物流单号" class="form-control shipper_sn" value="">
                            </div>
                            <input type="hidden" value="{$info.id}" id="id">
                            <button type="button" class="btn btn-w-m btn-primary" onclick="sendOrder()">发货</button>
                        </div>
                    </div>
                </div>
                {/if}
                {if $info['status'] == 2}
                <div class="ibox-content">
                    <div class="box-item">
                        <div class="form-group row"><label class="col-sm-1 col-form-label">发货信息</label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" value="物流公司：{$info.shipper_name}" readonly>
                            </div>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" value="物流单号：{$info.shipper_sn}" readonly>
                            </div>
                        </div>
                    </div>
                </div>
                {/if}
            </div>

            <button type="button" class="btn btn-w-m btn-default back-page">返回</button>
        </div>
    </div>
</div>{/block}

{block name='js'}
<script src="/static/layui/layui.js"></script>
<script type="text/javascript">
    function sendOrder() {
        var id = $('#id').val();
        var shipper_name = $('.shipper_name').val();
        var shipper_sn = $('.shipper_sn').val();
        $.post('/admin/manage/sendOrder', {id, shipper_sn, shipper_name}, res => {
            if (res.result == 1) {
                layer.msg(res.msg, {icon: 1, timer: 500}, () => {
                    window.location.reload()
                })
            } else {
                layer.msg(res.msg, {icon: 2, timer: 500})
            }
        }, 'json')
    }
</script>{/block}